<template>
  <div>
    <el-table
      :data="tableData"
      border
      style="width: 100%">
      <el-table-column
        prop="id"
        label="Id"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话"
        width="180">
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮箱"
        width="180">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev, pager, next"
      :total="100"
      :page-size="5"
      current-page="1"
      @current-change ="goPage"
      align="right">
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: 'deparment',
  data () {
    return {
      tableData:[],
      total:0,
      pageSize:5,
      currentPage:1
    }
  },
  methods:{
    goPage(currentPage){
      this.currentPage = currentPage;
      this.list();
    },
    list(){
      this.$http.get("/department/queryData", {"currentPage":this.currentPage,"pageSize":this.pageSize}).then( result => {
        this.tableData = result.data.data;
        // 设置返回的总条数给total
        this.total = result.data.totals;
      }).catch( error => {
        this.$message.error('系统繁忙，请重试！');
        console.log(result);
      })
    }
  },
  mounted() {
    this.list();
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
